// import request from '@/utils/request'
// export const getRoleList = (pageNum = 1, pageSize = 10) => 
//     request.get('/role/list', {  params: { pageNum, pageSize }})
  
//   // 获取所有角色
//   export const getAllRoles = () => request.get('/role/all')
  
//   // 添加角色
//   export const addRole = (roleDTO) => request.post('/role', roleDTO)
  
//   // 更新角色
//   export const updateRole = (id, roleDTO) => request.put(`/role/${id}`, roleDTO)
  
//   // 删除角色
//   export const deleteRole = (id) => request.delete(`/role/${id}`)
  
//   // 分配权限
//   export const assignPermissions = (roleId, permissionIds) => 
//     request.post(`/role/${roleId}/permissions`, { permissionIds })


// src/api/roleControl.js
import request from '@/utils/request'

// 获取角色列表（分页）
export function getRoleList(pageNum, pageSize, params = {}) {
  return request({
    url: '/role/list',
    method: 'get',
    params: { pageNum, pageSize, ...params }
  })
}

// 获取所有角色
export function getAllRoles() {
  return request({
    url: '/role/all',
    method: 'get'
  })
}

// 添加角色
export function addRole(roleData) {
  return request({
    url: '/role',
    method: 'post',
    data: roleData
  })
}

// 更新角色
export function updateRole(id, roleData) {
  return request({
    url: `/role/${id}`,
    method: 'put',
    data: roleData
  })
}

// 删除角色
export function deleteRole(id) {
  return request({
    url: `/role/${id}`,
    method: 'delete'
  })
}

// 分配权限
export function assignPermissions(roleId, permissionIds) {
  return request({
    url: `/role/${roleId}/permissions`,
    method: 'post',
    data: { permissionIds }
  })
}

// 获取角色已有权限
export function getRolePermissions(roleId) {
  return request({
    url: `/role/${roleId}/permissions`,
    method: 'get'
  })
}